package org.huangrui.juc.source.cf;

import java.util.concurrent.*;

/**
 * @Author hr
 * @Create 2024-04-01 12:53
 */
public class T08_CompletableFutureAPI {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture.supplyAsync(()->{
            return 1;
        }).thenApply(v-> v+2)
                .thenApply(v->v+3)
                .thenAccept(System.out::println);
        System.out.println("=======================================");
        System.out.println(CompletableFuture.supplyAsync(() -> "resultA").thenRun(() -> {}).join());
        System.out.println(CompletableFuture.supplyAsync(() -> "resultA").thenAccept(r -> System.out.println(r)).join());
        System.out.println(CompletableFuture.supplyAsync(() -> "resultA").thenApply(v -> v + " BD").join());
    }
}
